<template>
	<view><baseForm :column.sync="column" @submitFun="submitFun" @changeColumn="changeColumn" :submitStatus="submitDisable"></baseForm></view>
</template>

<script>
import baseForm from '@/wxcomponents/form/form.vue';
import formMixins from '@/libs/formMixins.js';
import { format } from '@/libs/common.js';
import login from '@/libs/login.js';
export default {
	mixins: [formMixins],
	data() {
		return {
			column: [
				{
					label: '报修日期',
					name: 'dinnerTime',
					type: 'picker',
					mode: 'date',
					required: true,
					disabled: true,
					value: format('YY-mm-dd', new Date()),
					text: format('YY-mm-dd', new Date())
				},
				{
					label: '故障位置',
					name: 'malfunctionLocation',
					type: 'normalInput',
					disabled: false,
					required: true,
					value: ''
				},
				{
					label: '报修内容',
					name: 'applyDetails',
					type: 'normalInput',
					disabled: false,
					required: true,
					value: ''
				}
			]
		};
	},
	async onLoad() {},
	methods: {
		async submitFun() {
			let user = await login.getStorage('user');
			let params = {
				applicantJobNumber: user.number, //报修人教职工号
				malfunctionLocation: this.column[1].value, //故障位置
				applyDetails: this.column[2].value,
				applyDate: this.column[0].value.substring(0, 10)
			};
			let rules = [
				{
					key: 'malfunctionLocation',
					checkFunc(value) {
						if (!value)	return false;
						return true;
					},
					errMsg: '请输入故障位置'
				},
				{
					key: 'applyDetails',
					checkFunc(value) {
						if (!value)	return false;
						return true;
					},
					errMsg: '请输入报修内容'
				},
			]
			let checkRes = this.checkFormIsPassRules(params, rules);
			if (!checkRes.isPass) {
				this.showToast(checkRes.errMsg);
				return;
			}
			let resp = await this.$http.post({
				url: '/oa/wechat/repairsApply/save',
				data: params
			});
			this.showToast('提交成功',()=> {uni.navigateBack()});
		}
	},
	components: {
		baseForm
	}
};
</script>

<style></style>
